import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-23
 * Time: 20:07
 */
public class Test {
    public static User login() {
        System.out.println("请输入您的姓名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("欢迎来到图书管理系统，请选择您的身份：1->管理员  2->普通用户");
        int choice = -1;
        do {
            choice = scanner.nextInt();
            if(choice != 1 && choice != 2) {
                System.out.println("无对应身份，请重新输入！");
            }
        }while (choice != 1 && choice != 2);
            if(choice == 1) {
                return new AdminUser(name);
            }else {
                return new NormalUser(name);
            }
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();

        User user = login();

       while(true) {

           int choice = user.menu();

           user.doOperation(choice,bookList);

       }
    }

}
